package com.zhou.jiancai.adapter;

import android.content.Context;
import android.os.Handler;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.zhou.jiancai.R;

/**
 * Created by Administrator on 2017/3/17.
 */


 public class MyAdapterImplementation extends RecyclerView.Adapter<MyAdapterImplementation.MyViewHolderInner> {
    private Context context;
    private int [] images;

   Handler mhandler;
    public MyAdapterImplementation (Context context,int[] iamges){
        this.context=context;
        this.images=iamges;



    }
    @Override
    public MyViewHolderInner onCreateViewHolder(ViewGroup parent, int viewType) {
     View view  =LayoutInflater.from(context).inflate(R.layout.home_ads_view,parent,false);
        MyViewHolderInner myViewHolderInner=new MyViewHolderInner(view);

        return myViewHolderInner;
    }

    @Override
    public void onBindViewHolder(MyViewHolderInner holder, int position) {
     int  curr =position%3;



            holder.imageView.setImageResource(images[curr]);
    }

    @Override
    public int getItemCount() {
        return 3;
    }
    class MyViewHolderInner extends RecyclerView.ViewHolder{

        private final ImageView imageView;

        public MyViewHolderInner(View itemView) {
            super(itemView);
            imageView = (ImageView) itemView.findViewById(R.id.ads_view);
        }
    }
}
